package br.com.clinica.supercao.dao.impl;

import java.util.ArrayList;
import java.util.List;

import br.com.clinica.supercao.JPA.GenericDAOSuperCao;
import br.com.clinica.supercao.dao.AnimalDAO;
import br.com.clinica.supercao.entity.Animal;
import br.com.clinica.supercao.entity.filter.AnimalSearchFilter;
import br.com.rpteixeira.dao.AbstractEntityDAO;
import br.com.rpteixeira.persistence.DAO;

public class AnimalDAOImpl extends
		AbstractEntityDAO<Animal, AnimalSearchFilter> implements AnimalDAO {

	@Override
	protected void doPrepareQuery(StringBuffer query,
			AnimalSearchFilter entitySearchFilter) {
		
	}

	@Override
	protected Object[] doPrepareQueryFrom(StringBuffer query,
			AnimalSearchFilter entitysearchfilter) {
		List<Object> args= new ArrayList<Object>();
		if(entitysearchfilter.getNome()!=null && !entitysearchfilter.getNome().isEmpty()){
			query.append(" and oEntidade.nome LIKE ?");
			args.add(entitysearchfilter.getNome());
		}
		return args.toArray();
	}

	@Override
	public DAO<Animal> getDao() {
		return new GenericDAOSuperCao<Animal>();
	}

	

}
